<?php
namespace app\port\controller;
class Index extends Common{
    /**
     * 获取app版本号
     * @return [type] [description]
     */
    function index($type="app"){
        $version='';
        $app_url='';
        if($type==='manage'){ //管理端版本
            $version=config('setting.manage_version');
            $app_url=config('config.manage_url');
        }else if($type==='mult'){ //分身版本
            $version=config('setting.mult_version');
            $app_url=config('config.mult_url');
        }else{
            $version=config('setting.version');
            $app_url=config('config.app_url');
        }
        return json($version,0,['version'=>$version,'url'=>$app_url]);
    }
    /**
     * 初始化载入设备、微信、未读等数量统计
     * @return [type] [description]
     */
    function initTotal(){
        $uid=$this->user['id'];
        $devs=model('device')->where(['member_id'=>$uid])->count();
        $softs=model('software')->where(['member_id'=>$uid])->count();
        $socials=model('social')->where(['member_id'=>$uid])->count();
        // 聊天组件 用户未读信息
        $unreadIds=model('weixinlogs')->unreadIds($uid);
        $messageTotal=0;
        foreach ($unreadIds as $v) {
            $messageTotal+=$v;
        }
        // $task=model('tasking')->where(['member_id'=>$uid,'status'=>0])->order('id desc')->find();
        // $tasking=model('tasking')->where(['member_id'=>$uid],'status'=>1)->order('id desc')->find();
        $rs=[
            'devTotal'=>$devs,
            'softTotal'=>$softs,
            'memberTotal'=>$socials,
            'messageTotal'=>$messageTotal,
        ];
        return json('',0,$rs);
    }
}